package org.bigdata.framework.core.protocol;

import java.util.HashMap;
import java.util.List;

import org.bigdata.framework.core.model.CmsNavbar;
import org.bigdata.framework.core.model.CmsNewsModule;
import org.bigdata.framework.core.service.ICmsNavbarService;
import org.bigdata.framework.core.service.ICmsNewsModuleService;
import org.bigdata.framework.core.utils.MybatisPlusTools;
import org.springframework.beans.factory.annotation.Autowired;

import com.baomidou.mybatisplus.plugins.Page;

public class CmsService implements ICmsService {
	
	@Autowired
	private ICmsNavbarService cmsNavbarService;
	@Autowired
	private ICmsNewsModuleService cmsNewsModuleService;

	@Override
	public CmsNavbar saveCmsNavbar(CmsNavbar cmsNavbar) {
		boolean r = cmsNavbarService.insert(cmsNavbar);
		if (r) {
			return cmsNavbar;
		}
		return null;
	}

	@Override
	public CmsNavbar editCmsNavbar(CmsNavbar cmsNavbar) {
		boolean r = cmsNavbarService.updateAllColumnById(cmsNavbar);
		if (r) {
			return cmsNavbar;
		}
		return null;
	}

	@Override
	public void deleteCmsNavbar(CmsNavbar cmsNavbar) {
		boolean r = cmsNavbarService.deleteById(cmsNavbar.getId());
		if (r) {
			System.out.println("cmsNavbar 删除成功>>>" + cmsNavbar.getId());
		}

	}

	@Override
	public CmsNavbar findCmsNavbar(Integer id) {

		return cmsNavbarService.selectById(id);
	}

	@Override
	public List<CmsNavbar> getCmsNavbar() {
		
		return cmsNavbarService.selectList(null);
	}

	@Override
	public List<CmsNavbar> getCmsNavbar(HashMap<String, Object> queryParams, int pageNumber, int pageSize) {
		return cmsNavbarService.selectPage(
				new Page<CmsNavbar>(pageNumber, pageSize),
				new MybatisPlusTools<CmsNavbar>().getEwByList(queryParams))
				.getRecords();
	}

	@Override
	public Integer getCmsNavbarCount(HashMap<String, Object> queryParams) {
		return cmsNavbarService.selectCount(new MybatisPlusTools<CmsNavbar>()
				.getEwByCount(queryParams));
	}

	@Override
	public CmsNewsModule saveCmsNewsModule(CmsNewsModule cmsNewsModule) {
		boolean r = cmsNewsModuleService.insert(cmsNewsModule);
		if (r) {
			return cmsNewsModule;
		}
		return null;
	}

	@Override
	public CmsNewsModule editCmsNewsModule(CmsNewsModule cmsNewsModule) {
		boolean r = cmsNewsModuleService.updateAllColumnById(cmsNewsModule);
		if (r) {
			return cmsNewsModule;
		}
		return null;
	}

	@Override
	public void deleteCmsNewsModule(CmsNewsModule cmsNewsModule) {
		boolean r = cmsNewsModuleService.deleteById(cmsNewsModule.getId());
		if (r) {
			System.out.println("cmsNewsModule 删除成功>>>" + cmsNewsModule.getId());
		}

	}

	@Override
	public CmsNewsModule findCmsNewsModule(Integer id) {
		
		return cmsNewsModuleService.selectById(id);
	}

	@Override
	public List<CmsNewsModule> getCmsNewsModule() {

		return cmsNewsModuleService.selectList(null);
	}

	@Override
	public List<CmsNewsModule> getCmsNewsModule(HashMap<String, Object> queryParams, int pageNumber, int pageSize) {
		return cmsNewsModuleService.selectPage(
				new Page<CmsNewsModule>(pageNumber, pageSize),
				new MybatisPlusTools<CmsNewsModule>().getEwByList(queryParams))
				.getRecords();
	}

	@Override
	public Integer getCmsNewsModuleCount(HashMap<String, Object> queryParams) {
		return cmsNewsModuleService.selectCount(new MybatisPlusTools<CmsNewsModule>()
				.getEwByCount(queryParams));
	}

}
